package com.hxy.health.platform.service.impl;

import com.hxy.health.platform.dao.AppointmentMapper;
import com.hxy.health.platform.pojo.Appointment;
import com.hxy.health.platform.service.AppointmentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class AppointmentServiceImpl implements AppointmentService {

    @Autowired
    private AppointmentMapper appointmentMapper;

    /**
     * 查询用户预定信息
     * @param email
     * @return
     */
    @Override
    public Appointment getByEmail(String email) {
        return appointmentMapper.getByEmail(email);
    }

    /**
     * 预订到店
     * @param appointment
     * @return
     */
    @Override
    public int addAppointment(Appointment appointment) {
        Appointment appointment1 = new Appointment();
        appointment1.setAdbout(appointment.getAdbout());
        appointment1.setApTime(appointment.getApTime());
        appointment1.setAtTime(appointment.getAtTime());
        appointment1.setEmail(appointment.getEmail());
        appointment1.setName(appointment.getName());
        appointment1.setPhone(appointment.getPhone());
        return appointmentMapper.insertSelective(appointment1);
    }

    /**
     * 更新预定
     * @param appointment
     * @return
     */
    @Override
    public int editAppointment(Appointment appointment) {
        Appointment appointment1 = new Appointment();
        appointment1.setId(appointment.getId());
        appointment1.setAdbout(appointment.getAdbout());
        appointment1.setApTime(appointment.getApTime());
        appointment1.setAtTime(appointment.getAtTime());
        appointment1.setEmail(appointment.getEmail());
        appointment1.setName(appointment.getName());
        appointment1.setPhone(appointment.getPhone());
        return appointmentMapper.updateByPrimaryKeySelective(appointment1);
    }
}
